<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商户协议</title>
</head>
<link rel="stylesheet" href="__CSS__/supplies/bootstrap.min.css"/>
<link rel="stylesheet" href="__JS__/supplies/bootstrap-table/bootstrap-table.min.css">
<link rel="stylesheet" href="__ASSETS__/css/font-awesome.min.css"/>
<style type="text/css">
    html{
        height: 100%;
    }
    body{
        height: calc(100% - 20px);
        overflow: hidden;
    }
</style>
<body style="">
    <div class="body" style="height: 100%;overflow: hidden;">
        <div style="height: 80px;">
            <h2 style="float: left;">编辑商户协议</h2>
            <div class="btn" style="float: right;margin-top: 15px;">
                <button class="btn btn-default" data-dismiss="modal" onclick="saveBtn()">
                    <i class="icon-ok align-top bigger-125"></i>
                    保存
                </button>
                <!--<button type="button" class="btn btn-default bot" data-dismiss="modal" onclick="saveBtn()">保存</button>-->
            </div>
        </div>
        <div style="height: calc(100% - 90px);overflow: auto;">
            <div id="editor" type="text/plain" style="height: 100%;"></div>
        </div>
    </div>

</body>
<script type="text/javascript" charset="utf-8" src="__JS__/supplies/jquery.min.js" rel="script" ></script>
<script type="text/javascript" charset="utf-8" src="__JS__/supplies/common.js" rel="script" ></script>
<script type="text/javascript" charset="utf-8" src="__JS__/UEditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__JS__/UEditor/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="__JS__/UEditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" charset="utf-8" src="__JS__/supplies/layer/layer.js"></script>
<script>
    var id;
    var ue = UE.getEditor('editor', {
        elementPathEnabled: false, //删除元素路径
        wordCount: false    //删除字数统计
    });

    ue.addListener('ready', function (editor) {
        $.ajax({
            url: '{:url("admin/Setting/getProtocolInfo")}',
            type: "POST",
            data: {'type': 2},
            success: function (data) {
                if(data.status == 200)
                {
                    id= data.data.id;
                    ue.setContent(data.data.content);
                }
            }
        })
    });

    function saveBtn(){
        var val = UE.getEditor('editor').getContent();
        if(val==''){
            alert('请输入内容');
            return;
        }
        $.ajax({
            url: '{:url("admin/Setting/addUserProtocol")}',
            type: "POST",
            data: {'id':id,'content':val,'type': 2},
            success: function (data) {
                layer.alert(data.msg, function(index){
                    location.reload()
                });
            }
        })
    }
</script>
</html>